package com.pan.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pan.domain.Apply;
import com.pan.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ManagerDao extends BaseMapper<User> {
    //查看申请
    @Select("select * from tbl_apply")
    List<Apply> getAllApply();

    //逻辑删除
    @Update("update tbl_user set `delete` = 0 where id = #{id} and `delete` = 1")
    Boolean LogicDelete(Integer id);

    //修改部门
    @Update("update tbl_user set `deptno` = #{deptno} where id = #{id}")
    Boolean changeDeptno(Integer id,Integer deptno);

    //修改职位
    @Update("update tbl_user set `position` = #{position} where id = #{id}")
    Boolean changePosition(Integer id,String position);

    //修改薪水
    @Update("update tbl_user set `salary` = #{salary} where id = #{id}")
    Boolean changeSalary(Integer id,Integer salary);

    //申请处理，使用SQL映射文件配置
    Boolean applyManager(Apply apply);

    //逻辑删除，修改审批状态
    @Update("update tbl_apply set `delete` = 0 where name = #{name} and `delete` = 1")
    Boolean changeApplyCondition(Apply apply);

    //添加新管理员
    @Update("update tbl_user set `isadmin` = 1 where id = #{id}")
    Boolean setNewManager(Integer id);

}
